import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:icooker/pages/main/drawer_main.dart';
import 'package:icooker/providers/main_provider.dart';
import 'package:icooker/widgets/leading_widget.dart';
import 'package:provider/provider.dart';

import 'body_main.dart';
import 'bottom_nav_bar.dart';

/// 首页容器
class MainPage extends StatefulWidget {
  const MainPage({Key? key}) : super(key: key);

  @override
  _MainPageState createState() => _MainPageState();
}

class _MainPageState extends State<MainPage> {
  @override
  Widget build(BuildContext context) {
    return ChangeNotifierProvider(
      create: (_) => MainProvider(),
      child: Scaffold(
        // appBar: AppBar(
        //   elevation: 0,
        //   title: Text("美食杰"),
        //   leading: Builder(
        //     builder: (context) {
        //       return LeadingButton("assets/images/avatar.jpg", () {
        //         Scaffold.of(context).openDrawer();
        //       });
        //     },
        //   ),
        //   centerTitle: true,
        // ),
        body: Consumer<MainProvider>(
          builder: (context, provider, child) {
            return MainBody();
          },
        ),
        bottomNavigationBar: Consumer<MainProvider>(
          builder: (context, provider, child) {
            return MainBottombar();
          },
        ),
      ),
    );
  }
}
